<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page language="java" import="com.uft.model.entity.*,java.util.List"%>
<%@ page isELIgnored="false"%>

<script> 
        // wait for the DOM to be loaded 
         
        $(document).ready(function() { 
        	uftDeploy.init(<c:out value="${server.serverId}"/>);
        	$('#deployForm_<c:out value="${server.serverId}"/>').submit(function() {
        		var options = {
                        beforeSubmit: function(){
                            $("#submit_<c:out value="${server.serverId}"/>").attr("disabled", "disabled");
                             $("#sendEmail_<c:out value="${server.serverId}"/>").button( "disable" );
                        },
                        success: function(data){
                            if(data.Result == "OK"){
                                generateDiag("center","success", "Deploy Scheduled!");
                                $("#deployloadingImg_<c:out value="${server.serverId}"/>" ).show();
                                $("#submit_<c:out value="${server.serverId}"/>").attr("disabled", "disabled");
                                $("#endTime_<c:out value="${server.serverId}"/>").val( "" );
                                $("#status_<c:out value="${server.serverId}"/>").val( "" );
                                uftDeploy.submitDeploymentTask(<c:out value="${server.serverId}"/>);
                                
                            }else{
                                generateDiag("center","error", "Unable to schedule the Deployment");
                                $("#deployloadingImg_<c:out value="${server.serverId}"/>" ).hide();
                                $("#submit_<c:out value="${server.serverId}"/>").removeAttr("disabled");
                            }
                            
                        },
                        url: "addDeploymentTask.htm",
                        type: "POST",
                        dataType: 'json'
                    
                };
        		$(this).ajaxSubmit(options);
                return false;
        	});
        }); 
</script> 

<table width="100%" height="100%">
<tr>
	<td width="25%" height="100%" valign="top"> 
		<div id="deployOptions_<c:out value="${server.serverId}"/>" >
			<h3>Options</h3>
			<div>
				<form id="deployForm_<c:out value="${server.serverId}"/>" action="addDeploymentTask.htm" method="post">
					<input type="hidden" id="serverId" name="serverId" value="<c:out value="${server.serverId}"/>" /> 
				    
						<fieldset  class="ui-widget ui-widget-content">
							<legend>Options</legend>
								Send Email:<input type="text" name="email"  id="email"  class="text ui-widget-content ui-corner-all" />
								Deploy File:<select id="deployFile" name="deployFile" class="select ui-widget-content ui-corner-all">
												<option value="ALL">ALL</option>
										    	<c:forEach var="deployFile" items="${deployFiles}" >
													<option value="${deployFile}">${deployFile}</option>
												</c:forEach>
										    </select>
								<br>
								Auto Restart:<input type="checkbox" name="autoRestart"  id="autoRestart" class="checkbox ui-widget-content ui-corner-all"/>
						</fieldset>
						<table width="100%">
							<tr><td align="right"><button type="submit" name="submit"  id="submit_<c:out value="${server.serverId}"/>" >submit</button></td></tr>
						</table>
						
						
				</form>
				
			</div>
		</div>
	</td>
	<td valign="top">
		
		<form>
			<fieldset  class="ui-widget ui-widget-content">
						<legend>Info</legend>
						<table width="100%" >
							<tr>
								<td>Region:<input type="text" name="region"  id="region" disabled="true" 
								 value="<c:out value="${profile.region}"/>" class="text ui-state-disabled ui-widget-content ui-corner-all" /></td>
								 <td>Server Name:<input type="text" name="serverName"  id="serverName"  disabled="true"
								 value="<c:out value="${server.serverName}"/>" class="text ui-state-disabled ui-widget-content ui-corner-all" /></td>
								 <td>Server Hostname:<input type="text" name="hostname"  id="hostname"  disabled="true"
								 value="<c:out value="${server.serverHostname}"/>" class="text ui-state-disabled ui-widget-content ui-corner-all" /></td>
								 <td>Dmgr Name:<input type="text" name="dmgrName"  id="dmgrName"
								value="<c:out value="${profile.profileName}"/>" disabled="true"  class="text ui-state-disabled ui-widget-content ui-corner-all" /></td>
								<td>Dmgr Hostname:<input type="text" name="dmgrHost"  id="dmgrHost" 
								value="<c:out value="${profile.hostname}"/>" disabled="true"  class="text ui-state-disabled ui-widget-content ui-corner-all" /></td>
							</tr>
							<tr>
								<td>Start Time:<input type="text" name="startTime" id="startTime_<c:out value="${server.serverId}"/>" 
									disabled class="text ui-state-disabled ui-widget-content ui-corner-all" /></td>
								<td>End Time:<input type="text" name="endTime" id="endTime_<c:out value="${server.serverId}"/>"  
									disabled class="text ui-state-disabled ui-widget-content ui-corner-all" /></td>
								<td>Status:<input type="text" name="status" id="status_<c:out value="${server.serverId}"/>"  
									disabled class="text ui-state-disabled ui-widget-content ui-corner-all" /></td>
								<td colspan="2" align="right">
									<button id="sendEmail_<c:out value="${server.serverId}"/>">Send Email</button>
								</td>
							</tr>
						</table>
				</fieldset>
		</form>
		<div id="deployOutputTab_<c:out value="${server.serverId}"/>">
				 <ul>
				    <li><a href="#output_<c:out value="${server.serverId}"/>">Output</a></li>
				    <li><a href="#error_<c:out value="${server.serverId}"/>">Error</a></li>
				    <span class="deployLoading">
               				<img id="deployloadingImg_<c:out value="${server.serverId}"/>" src="<c:url value="/images/16/ajax-loader.gif"/>" />
         		   </span>
				  </ul>
				  <div id="output_<c:out value="${server.serverId}"/>">
				  </div>
				   <div id="error_<c:out value="${server.serverId}"/>">
				    
				  </div>
		</div>
	</td>
	
</tr>
</table>


